package com.test5;

import java.io.BufferedReader;
import java.io.FileReader;

public class BufferedReaderTest {
    public static void main(String[] args) throws Exception {
        //创建缓冲流
        FileReader fr = new FileReader("C:\\Users\\LDH\\Desktop\\test2.txt");
        BufferedReader br = new BufferedReader(fr);
        //读取
        //缓冲区读取
        char[] buf = new char[1024];
        int count = 0;
        while ((count = br.read(buf)) != -1){
            System.out.println(new String(buf,0,count));
        }
        //一行一行的读取
        String line = null;
        while ((line = br.readLine()) != null){
            System.out.println(line);
        }
        //关闭
        br.close();
    }
}
